<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript">
        var arr = [];
        // alert(arr.length); // 0

        arr[0] = 2;
        // alert(arr[0]); // 2
        // alert(arr.length);

        arr[2] = 1;
        // alert(arr.length);

        arr[3] = "abc";
        for (let i = 0; i < arr.length; i++) {
            console.log(arr[i]);
        }
    </script>
</head>
<body>

</body>
</html>